package dnl.toolbox.dto;

import java.util.IdentityHashMap;
import java.util.Map;

/**
 * A <code>ConversionContext</code> is necessary in order to keep consistent
 * references accross conversions.
 * 
 * @author daniel
 * 
 */
@SuppressWarnings("unchecked")
public class ConversionContext {

	private Map cachedConversions = new IdentityHashMap();
	private DtoConversions contextConversions;

	public ConversionContext(DtoConversions contextConversions) {
		this.contextConversions = contextConversions;
	}

	public void registerConvertedObject(Object obj, Object converted) {
		cachedConversions.put(obj, converted);
	}

	public Object retrieveConvertedObject(Object obj) {
		return cachedConversions.get(obj);
	}

	public DtoConversions getContextConversions() {
		return contextConversions;
	}

	public void setContextConversions(DtoConversions contextConversions) {
		this.contextConversions = contextConversions;
	}

}
